#!/bin/sh

#
# --- VARIABLES A MODIFIER
#
NOM_ARCHIVE=UserManager
JAVA_PATH=/usr/bin

#
# --- VARIABLES GLOBALES
#
JAR="$JAVA_PATH"/jar
JAVAC="$JAVA_PATH"/javac
JAR_PATH=../../lib
CLASSPATH=build/WEB-INF/classes/:build/classes/:"$JAR_PATH"/jsr311-api.jar:"$JAR_PATH"/jersey-gf-bundle.jar

#
# --- DIRECTIVES DE COMPILATION
#
echo "\nCompilation du service REST : $NOM_SERVICE\n"
mkdir -p build/WEB-INF/classes/Shared/

echo "$CLASSPATH"
"$JAVAC" -classpath "$CLASSPATH"  -d build/WEB-INF/classes/ ../Shared/_Config.java ../Shared/Players.java ../Shared/Party.java ../Shared/Card.java ../Shared/Player.java
"$JAVAC" -classpath "$CLASSPATH"  -d build/WEB-INF/classes/ UserManager.java

echo "\nGeneration de l'archive $NOM_ARCHIVE.war\n"
current_path=`pwd`
cp -R META-INF "build"
cp -R WEB-INF/web.xml "build/WEB-INF/"

cd "$current_path/build"
rm -f "$NOM_ARCHIVE".war        
"$JAR" -cf "$NOM_ARCHIVE".war META-INF WEB-INF
cd "$current_path"

